import pytest

from api.base_service_member import MemberService
from api.py_order_service import OrderSettingService

data1 = [("13820220011", "13820220011"), ("13020226110", None)]
data2 = [(["2022.5"], [1197]),
         (["2022.13"], [1214]),
         ([2022.13], None)]

data3 = [("2022-10-19 12:12:12", 90, True)]


class TestMemberService(object):

    @pytest.mark.parametrize("tel,expect", data1)
    def test_find_by_telephone(self, tel, expect):
        ms = MemberService()
        resp = ms.find_by_telephone(tel)
        print("打印结果", resp)

        if resp == None:
            assert expect is resp
        else:
            assert expect == resp.get("phoneNumber")

    @pytest.mark.parametrize("months,expect", data2)
    def test_find_member_count_by_months_not_exists(self, months, expect):
        ms = MemberService()
        resp = ms.find_member_count_by_months(months)
        print("响应结果", resp)
        assert expect == resp

    @pytest.mark.parametrize("time,quantity,expect", data3)
    def test_add(self, time, quantity, expect):
        ms = OrderSettingService()
        resp = ms.add(time, quantity)
        print("响应结果", resp)
        assert expect is resp
